package com.hoko.blur.opengl.framebuffer;

import ohos.agp.render.opengl.GLES20;

import com.hoko.blur.api.IFrameBuffer;

/**
 * 帧缓冲工厂
 *
 * @since 2021/08/03
 */
public class FrameBufferFactory {

    /**
     * 创建
     *
     * @return {@link IFrameBuffer}
     */
    public static IFrameBuffer create() {
        return new FrameBuffer();
    }

    /**
     * 创建
     *
     * @param id id
     * @return {@link IFrameBuffer}
     */
    public static IFrameBuffer create(int id) {
        return new FrameBuffer(id);
    }

    /**
     * 得到显示帧缓冲
     *
     * @return {@link IFrameBuffer}
     */
    public static IFrameBuffer getDisplayFrameBuffer() {
        // Get the bound FBO (On Screen)
        final int[] displayFbo = new int[1];
//        GLES20.glGetIntegerv(GLES20.GL_FRAMEBUFFER_BINDING, displayFbo, 0); ??????
        GLES20.glGetIntegerv(GLES20.GL_FRAMEBUFFER_COMPLETE, displayFbo);
        return create(displayFbo[0]);
    }
}
